#include "testsummator.h"
#include "../../app/summator/summator.h"
#include <QSignalSpy>
#include <QtTest/QtTest>


TestSummator::TestSummator():
QObject (NULL), m_sum(new Summator(this))
{
}
TestSummator::TestSummator(QObject *parent) :
    QObject(parent),  m_sum(new Summator(this))
{   
    m_sum -> setA(0);
    m_sum -> setB(0);
}

void TestSummator::TestSummator::test_valueChanged()
{
    QSignalSpy spy(m_sum, SIGNAL(valueChanged()));
    m_sum->setA(2);
    m_sum->setB(3);
    QCOMPARE(spy.count(),2);
    m_sum->setB(3);
    QCOMPARE(spy.count(),2);
}


void TestSummator::TestSummator::test_setA()
{
    m_sum->setA(10);
    m_sum->setB(10);
    QCOMPARE(m_sum->sum(), 20);
}

void TestSummator::TestSummator::test_setB()
{
    m_sum->setA(0);
    m_sum->setB(10);
    QCOMPARE(m_sum->sum(), 10);
}

void TestSummator::TestSummator::test_sum()
{
    m_sum->setA(15);
    m_sum->setB(10);
    QCOMPARE(m_sum->sum(), 25);
}


